import {
  reqCategoryList,
  reqGetBannerList,
  reqFloorList
} from "@/api"
export default {
  namespaced: true,
  state: {
    categoryList: [],
    bannerList: [],
    floorList:[]
  },
  getters: {},
  actions: {
    async categoryList(context) {
      const result = await reqCategoryList()
      // console.log(result);
      if (result.code === 200) {
        context.commit('CATEGORYLIST', result.data)
        // console.log(context);
      }
    },
    // 获取首页轮播图数据
    async getBannerList(context) {
      let result = await reqGetBannerList()
      if (result.code == 200) {
        context.commit('GETBANNERLIST', result.data)
      }
    },
    async getFloorList(context) {
      let result = await reqFloorList()
      if (result.code == 200) {
        context.commit('GETFLOORLIST', result.data)
      }
    }
  },
  mutations: {
    CATEGORYLIST(state, val) {
      // console.log(val, '---');
      state.categoryList = val
    },
    GETBANNERLIST(state, val) {
      // console.log(val);
      state.bannerList = val
    },
    GETFLOORLIST(state, val) {
      // console.log(val);
      state.floorList=val
    }
  },
}